package realQuestion.wande;

import java.util.Arrays;

public class Test {

    public static void findOffSwitchByChange(int[] powerSwitchOff, int[] powerSwitch) {
       //TODO: 整体思路可以理解为从开关中按照遍历依次选取三个开关不做处理，其余12个开关闭合，
        //TODO:  此时如果灯泡亮了就代表前面所选取的开始是处于闭合状态的
        int n=powerSwitch.length;
            for(int i=0;i<n;i++){
                for (int j=i+1;j<n;j++){
                    for (int k = j+1; k <n ; k++) {
                        //TODO: 用这样的(powerSwitch[i]|powerSwitch[j]|powerSwitch[k])==0形式表示灯亮了
                        //TODO:如果判断条件成立就代表选中的三个开关为闭合状态

                            if ((powerSwitch[i]|powerSwitch[j]|powerSwitch[k])==0){
                                powerSwitchOff[0]=i;
                            powerSwitchOff[1]=j;
                            powerSwitchOff[2]=k;
                            break;
                        }

                    }
                }
            }
    }



    public static  void findOffSwitchByShort(int[] powerSwitchOff, int[] powerSwitch) {

        int switchCount = powerSwitch.length;
        int offSwitchCount=0;
        int currentSwitch=0;

        while (currentSwitch<switchCount&&offSwitchCount<3){

            if (powerSwitch[currentSwitch]==0){
                powerSwitchOff[offSwitchCount]=currentSwitch;
                offSwitchCount++;
            }
            if (offSwitchCount==3){
                break;
            }
            currentSwitch++;
        }


    }

    public static void main(String[] args) {
        int[] power_switch={1,0,1,1,1,0,1,1,1,1,0,1,1,1,1};
       int[] ans=new int[3];
       findOffSwitchByChange(ans,power_switch);
       findOffSwitchByShort(ans,power_switch);
        String s = Arrays.toString(ans);
        String substring = s.substring(1, s.length() - 1);
        System.out.println("int power_switch_off[3]={"+ substring+"};");


    }




}
